import {post,get} from "./common";
import { reactive } from "vue";

const HOST = 'https://s10.z100.vip:9043'
const FILE_HOST='http://s3.z100.vip:14812'

const login = (params)=>{
    // const params = reactive({
    //     username: "a",
    //     password: "b"
    // })
    return post(HOST + '/chat/login', params);
}

const getOnline = ()=>{
    return get(HOST + '/chat/online');
}

//获取id为param用户的所有聊天记录
const getAllHistory = (id)=>{
    const params = reactive({
        id: id,
    })
    return get(HOST + '/chat/getAll', params)
}

const uploadFile=(file)=>{
    let data=new FormData();
    data.append("bucketName", "temp");
    data.append('file', file);
    return post(FILE_HOST + '/demo/upload', data, {"Content-Type":"multipart/form-data"});
}

export {
    login,
    getOnline,
    getAllHistory,
    uploadFile,
}